home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’91 / ColorHack 1991 / the hack / xxWDEF.a < prev   
Encoding:
Text File  |  1991-06-20  |  3.3 KB  |  127 lines  |  [TEXT/MPS ]

  1.              BLANKS        ON
  2.             STRING        ASIS
  3.  
  4.             PRINT        OFF
  5.             INCLUDE        'ToolEqu.a'
  6.             INCLUDE        'Traps.a'
  7.             INCLUDE        'SysEqu.a'
  8.             INCLUDE        'QuickEqu.a'
  9.             PRINT        ON
  10.             
  11. WDEF0        PROC        EXPORT
  12.  
  13. ;
  14. ;  FUNCTION   DocProc(selector: INTEGER;
  15. ;                      window: WindowPtr,
  16. ;                      message: INTEGER;
  17. ;                      parameter: LongInt): LongInt
  18.  
  19. LinkSize    EQU        -34
  20. grafRsrcH    equ        -16
  21. oldResRef    equ        -12
  22. wdef0state    equ        -8
  23. wdefhandle    equ        -4
  24.  
  25. message        EQU        12            ;                                <C666/22Jan87> DAF
  26.  
  27. HasZoom     EQU     3            ; bit 3 is zoom bit             <EHB 29Aug85>
  28. hasGrow     EQU     2            ; bit 2 is grow bit             <EHB 29Aug85>
  29.  
  30. DocProc
  31.             BRA.S    DP1
  32.  
  33. ; standard header
  34.  
  35.             DC.W    0                    ; flags word
  36.             DC.B    'WDEF'                ; resource type
  37.             DC.W    0                    ; resource ID
  38.             DC.W    10                    ; version number
  39.  
  40. DP1
  41.             LINK    A6,#LinkSize         ; set up a stack frame to address parameters
  42.             MOVEM.L D3-D7/A1-A4,-(SP)    ; save work registers
  43.             
  44.             clr.w    -(sp)
  45.             _CurResFile
  46.             move.w    (sp)+,oldResRef(a6)    ; save off the current res ref number
  47.             
  48.             clr.w    -(sp)                ; res ref number of system file
  49.             _UseResFile                    ; point to system file
  50.             
  51.             clr.l    -(sp)                ; clear area for handle
  52.             move.l    #'WDEF',-(sp)        ; resource type
  53.             clr.w    -(sp)                ; res number is zero
  54.             _Get1Resource                ; get handle to system wdef resource
  55.             move.l    (sp)+,wdefhandle(a6) ; save the handle
  56.             
  57.             move.w    oldResRef(a6),-(sp)     ; original res ref number
  58.             _UseResFile                    ; reset it
  59.             
  60.             move.w    18(a6),d0
  61.             andi.w    #$000f,d0
  62.             cmpi.w    #1,d0                ; is it a dialog type ?
  63.             beq.s    @2                    ; if so then skip
  64.             
  65.             clr.l    -(sp)                ; clear area for handle
  66.             move.l    #'GRAF',-(sp)        ; resource type
  67.             clr.w    -(sp)                ; res number is zero
  68.             _GetResource                ; get handle to our interesting GRAF resource
  69.             move.l    (sp)+,grafRsrcH(a6) ; save the handle
  70.             
  71.             move.l    grafRsrcH(a6),a0    ; get the handle
  72.             move.l    (a0),a0                ; de-ref it
  73.             tst.l    (a0)                ; see if the first std proc has been inited.
  74.             bne.s    @1                    ; if non-zero then it's already in
  75.             
  76.             bsr        StartUpGRAF            ; go start it
  77. @1
  78.             move.l    grafRsrcH(a6),a0    ; get the handle
  79.             move.l    (a0),a0                ; de-ref it
  80.             move.l    14(a6),a1            ; get the window ptr
  81.             move.l    a0,grafProcs(a1)    ; set the grafproc patch
  82. @2
  83.             move.l    wdefhandle(a6),a0    ;
  84.             _HGetState                    ;
  85.             move.b    d0,wdef0state(a6)    ; save the state
  86.             
  87.             move.l    wdefhandle(a6),a0    ;
  88.             _HLock                        ;
  89.             
  90.             clr.l    -(sp)                ; result
  91.             move.w    18(a6),-(sp)        ; selector
  92.             move.l    14(a6),-(sp)        ; window
  93.             move.w    12(a6),-(sp)        ; message
  94.             move.l    8(a6),-(sp)            ; parameter
  95.             move.l    wdefhandle(a6),a0    ; handle to wdef
  96.             move.l    (a0),a0                ; de-ref it
  97.             jsr        (a0)                ; call the original wdef
  98.             move.l    (sp)+,20(a6)        ; return result
  99.             
  100.             move.l    wdefhandle(a6),a0    ;
  101.             move.b    wdef0state(a6),d0    ; the original state
  102.             _HSetState                    ;
  103.             
  104.             MOVEM.L (SP)+,D3-D7/A1-A4    ; restore work registers
  105.             UNLK    A6                    ; unlink stack frame
  106.             MOVE.L    (SP)+,A0            ; get return address
  107.             ADD     #12,SP                ; strip parameters
  108.             JMP     (A0)                ; return to caller
  109.             
  110. StartUpGRAF
  111.             move.l    grafRsrcH(a6),a0    ;
  112.             _HLock                        ; lock it down for-ever
  113.             
  114.             move.l    grafRsrcH(a6),a0    ;
  115.             move.l    (a0),-(sp)            ; put it on the stack
  116.             _SetStdProcs
  117.             
  118.             move.l    grafRsrcH(a6),a0    ;
  119.             move.l    (a0),a0                ; de-ref it
  120.             move.l    (a0),52(a0)            ; copy the original StdText to our save area
  121.             lea.l    56(a0),a1            ; get the address of where our hack starts at
  122.             move.l    a1,(a0)                ; and patch the StdProc
  123.             
  124.             rts
  125.             
  126.             endp
  127.             end